sound object

This method will set up the sound object for playback using data that is already stored in memory, as opposed to reading it from a file on disk like the load method does.

bool load_from_memory(string data)

Parameters:
data
A string with the data that is to be loaded.

Return value:
true on success, false on failure.

Remarks:
The data must be a valid Ogg Vorbis or Wave stream, with or without encryption. If the data is encrypted, the engine will decrypt it automatically using the global sound decryption key. The data is copied from your string into an internal buffer, so there is no need to keep your string around after this function has returned.

A loaded sound is completely put into memory when it is first created. This means that more of the system memory is taken up, but this also lowers the CPU usage considerably as all the audio data is available at all times. Loaded sounds should be used for most things that are meant to play quickly and/or often such as footsteps, gunshots, character noises and the like.

Example:
// Store the contents of a sound file in a string, and then set up a sound object with this data.

void main()
{
file reader;
reader.open("c:\\windows\\media\\ding.wav", "rb");
if(reader.active==false)
{
alert("Error", "The file could not be opened for reading.");
exit();
}
string data=reader.read();
reader.close();
sound test;
test.load_from_memory(data);
test.play_wait();
test.close();
}